/**
 * This file is part of Tamariba. Copyright (C) 2011 Michael Vogt <michael@tamariba.eu>, Patrick Hempel
 * <patrick@tamariba.eu>
 * 
 * Tamariba is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 * 
 * Tamariba is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License along with Tamariba. If not, see
 * <http://www.gnu.org/licenses/>.
 */
package eu.tamariba.html.user.client.activity;

import com.google.gwt.activity.shared.Activity;
import com.google.gwt.activity.shared.ActivityMapper;
import com.google.gwt.place.shared.Place;
import com.google.gwt.place.shared.PlaceController;
import com.google.inject.Inject;

import eu.tamariba.html.user.client.place.UserDisplayPlace;
import eu.tamariba.html.user.client.request.UserRequestFactory;
import eu.tamariba.html.user.client.ui.UserDisplayView;


public class UserActivityMapper implements ActivityMapper {
    private PlaceController placeController;
    private UserRequestFactory requests;
    
    @Inject
    public UserActivityMapper(UserRequestFactory requests, PlaceController placeController) {
        this.requests = requests;
        this.placeController = placeController;
    }

    @Override
    public Activity getActivity(Place place) {  
        if (place instanceof UserDisplayPlace)
            return makeDisplayActivity();
  
        return null;
    }
 
    private Activity makeDisplayActivity() {
        Activity activity = new UserDisplayActivity(placeController, UserDisplayView.instance(), requests);
        return new UserDisplayActivityWrapper(activity, requests, UserDisplayView.instance());
    }
}